//
//  Music.m
//  音乐播放(AVFoundation)
//
//  Created by dllo on 15/9/23.
//  Copyright (c) 2015年 天才谢美娜. All rights reserved.
//

#import "Music.h"
static Music *music;
//static NSInteger flag;
@implementation Music
+(Music *)shareInstance{
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        music = [[Music alloc]init];
    });
    return music;
}

//方法一: 调用一个暂停函数
-(void)playMusicWith:(NSString *)urlString{
//    if ([urlString isEqualToString:_currentURL]) {
//        [[[Music shareInstance] player] play];
//        [[SHD_music palyMusic] stopMusic];
//    }
//    else{
//        //记录当前歌曲用以下次判断
//        _currentURL = urlString;
//        //先暂停正在播放的歌曲
//        [_player pause];
//        [[[Music shareInstance] player] play];
        //初始化播放器
        _player = [[AVPlayer alloc]initWithURL:[NSURL URLWithString:urlString]];
//        //开始播放
        [_player play];
        [[GZ_Music shareInstance] stopMusic];
        [[SHD_music palyMusic] stopMusic];
//
//    }
}

-(void)pauseMusicWith:(NSString *)urlString{
   // if ([urlString isEqualToString:_currentURL]) {
        [_player pause];
        [[SHD_music palyMusic] playMusicAgain];
        [[GZ_Music shareInstance] playMusic];

 //   }
}

@end
